<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Cart extends CI_Controller{
	
	public function add(){
		
		$this->cart_model->store_product();
		
		if($this->input->is_ajax_request()){
			$this->showCart();
		}
		else{
			redirect("products/index", "location");
		}
	}
	
	public function showCart(){
		$this->load->view("cart/cart");		
	}
	
	public function remove(){
		
		$this->cart_model->destroy_cart();
		
		if($this->input->is_ajax_request()){
			$this->showCart();
		}
		else{
			redirect("products/index");
		}
		
		
	}
	
	public function checkout(){
		
		$data['title'] = "Checkout";
		
		$data['content'] = 'cart/checkout'; 
		//$data['cartPostContent'] = 'cart/cart';

		//Laddar index/masterpage
    	$this->load->view('index', $data);
	}
}